/*
 * @Date: 2025-07-18 11:33:53
 * @LastEditors: liucong congliu0913@126.com
 * @LastEditTime: 2025-07-18 14:18:20
 * @FilePath: \web_widget_demo\mainwindow.cpp
 */
#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // QWebEngineView *view = new QWebEngineView(this);
    // view->load(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + "/map.html"));
    // setCentralWidget(view);
    QWebEngineView *view = new QWebEngineView(this);
    view->load(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + "/map.html"));
    setCentralWidget(view);
    // QWebChannel 绑定
    QWebChannel *channel = new QWebChannel(this);
    MapBridge *bridge = new MapBridge(this);
    channel->registerObject("bridge", bridge);
    view->page()->setWebChannel(channel);
}

MainWindow::~MainWindow()
{
    delete ui;
}

